<div class="title">
  <div class='content'>
    修改-安装项目
  </div>
  <div class='tools'>
    <%= link_to '返回',
          install_items_installation_url(@install_item.installation),
          :remote => true,
          :method => :get,
          :id => :add_install_item
    %>
  </div>
</div>
<div class='info'>
  <%= form_for @install_item,
        :url => update_install_item_installation_url(@install_item),
        :remote => true,
        :method => :put do |f|
   %> 
  <div id='install_items' class='furnitures'>
  <table id='new_install_items' border="0" cellspacing="1" cellpadding="1">
    <tr>
      <th rowspan='2'>型号</th>
      <th rowspan='2'>材质</th>
      <th rowspan='2'>规格</th>
      <th colspan='3'>安装项</th>
    </tr>
    <tr>
      <th>存放点</th>
      <th>待安装数</th>
      <th>派工数</th>
    </tr>
    <tr>
      <td><%= @install_item.furniture.furniture_style.code %>-<%= @install_item.furniture.furniture_style.name %></td>
      <td><%= @install_item.furniture.material.code %>-<%= @install_item.furniture.material.name %></td>
      <td><%= @install_item.furniture.spec %></td>
      <td>
        <%= @install_item.furniture_logistic_stat_order_item.furniture_logistic_stat.dept.name %>
      </td>
      <td class='r'>
        <%= @install_item.can_be_installed_count %>件
      </td>
      <td class='c'>
        <%= link_to_function '-','',:id => "sub_sent_count_#{@install_item.id}" %>
        <%= f.text_field :has_been_sent_to_installer_count, :readonly => true, :class => :sent_count %>
        <%= link_to_function '+','',:id => "add_sent_count_#{@install_item.id}" %>  
        <script type="text/javascript" charset="utf-8">
        $(document).ready(function(){
          $('#add_sent_count_<%= @install_item.id %>').click(function(){
            if($('#install_item_has_been_sent_to_installer_count').val() < <%= @install_item.can_be_installed_count %> ) {
              $('#install_item_has_been_sent_to_installer_count').val(Number($('#install_item_has_been_sent_to_installer_count').val()) + 1);
              $('#sents_count').html(Number($('#sents_count').html()) + 1);
            }
          });
          $('#sub_sent_count_<%= @install_item.id %>').click(function(){
            if($('#install_item_has_been_sent_to_installer_count').val() > 1 ) {
              $('#install_item_has_been_sent_to_installer_count').val(Number($('#install_item_has_been_sent_to_installer_count').val()) - 1);
              $('#sents_count').html(Number($('#sents_count').html()) - 1);
            }
          });
        });
      </script>
      </td>
    </tr>
    <tr>
      <td colspan='6' class='r'>
        待安装<b id='can_be_installeds_count'><%= @install_item.can_be_installed_count %></b>件，共派工安装<b id='sents_count'><%= @install_item.has_been_sent_to_installer_count %></b>件
      </td>
    </tr>
  </table>
  </div>
  <div class="bottom">    
    <%= f.submit '派工安装', :class => 'bb' %>
    <%= link_to '返回',
          install_items_installation_url(@install_item.installation),
          :remote => true,
          :method => :get
     %>
  </div>  
  <% end %>
</div>